﻿
-- ================================================
-- Remarks: 
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Ivy_Sys_TableMaster_Insert')
	BEGIN
		DROP  Procedure  Ivy_Sys_TableMaster_Insert
	END

GO

CREATE PROCEDURE [Ivy_Sys_TableMaster_Insert] 
-- =============================================
-- Author:		<Mrinmoy Das>
-- Create date: <01/03/2011>
-- Description:	<Ivy_Sys_TableMaster_Insert>
-- =============================================
-- Add the parameters for the stored procedure here
	(
				@TableID int,
				@TableName varchar(50),
				@TableDescription varchar(max)= NULL,
				@TableSequenceNo int,
				@ModuleID int,
								
				@Sys_CreatedByID varchar(50)= NULL,
				@Sys_DeleteType int = 0,
				@Sys_OrganizationID int = NULL,
				@Sys_InitialPrimaryKeys varchar(max)= NULL,
				@Sys_WorkstationName varchar(50)= NULL
	)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	IF @Sys_WorkstationName = 'Default'	
	BEGIN
		SET @Sys_WorkstationName = (SELECT @@SERVERNAME);
	END
	DECLARE @CurrentDataTime datetime;
	SET @CurrentDataTime = GETDATE();

    INSERT INTO [Sys_TableMaster]
           (	
				[TableID],
				[TableName],
				[TableDescription],
				[TableSequenceNo],
				[ModuleID],

				[Sys_DateOfCreation],
				[Sys_DateOfModification],
				[Sys_CreatedByID],
				[Sys_ModifiedByID],
				[Sys_DeleteType],
				[Sys_IsDeleted],
				[Sys_OrganizationID],
				[Sys_InitialPrimaryKeys],
				[Sys_WorkstationName]
			)
     VALUES
           (
				@TableID, 
				@TableName, 
				@TableDescription,
				@TableSequenceNo, 
				@ModuleID,

				GETDATE(),
				GETDATE(),
				@Sys_CreatedByID,
				@Sys_CreatedByID,
				1,
				0,
				-1,
				NULL,
				@Sys_WorkstationName
			);
END
GO
